/**
 * 
 */
package org.metaverse.warehouse.util;

import java.util.Date;

import org.openrdf.model.Resource;
import org.openrdf.model.URI;
import org.openrdf.model.Value;

/**
 * @author vjache
 *
 */
@SuppressWarnings("serial")
public abstract class AbstractLazyCachedSenary extends AbstractLazySenary {

	private Date _lat;
	private URI _usr;
	private Resource _ctx;
	private Value _obj;
	private URI _pred;
	private Resource _subj;

	/* (non-Javadoc)
	 * @see org.metaverse.warehouse.Senary#getLastAssertTime()
	 */
	@Override
	public Date getLastAssertTime() {
		if(_lat==null)
			_lat = readLastAssertTime();
		return _lat;
	}

	protected abstract Date readLastAssertTime();

	/* (non-Javadoc)
	 * @see org.metaverse.warehouse.Senary#getUser()
	 */
	@Override
	public URI getUser() {
		if(_usr==null)
			_usr = readUser();
		return _usr;
	}

	protected abstract URI readUser();

	/* (non-Javadoc)
	 * @see org.openrdf.model.Statement#getContext()
	 */
	@Override
	public Resource getContext() {
		if(_ctx==null)
			_ctx = readContext();
		return _ctx;
	}

	protected abstract Resource readContext();

	/* (non-Javadoc)
	 * @see org.openrdf.model.Statement#getObject()
	 */
	@Override
	public Value getObject() {
		if(_obj==null)
			_obj=readObject();
		return _obj;
	}

	protected abstract Value readObject();

	/* (non-Javadoc)
	 * @see org.openrdf.model.Statement#getPredicate()
	 */
	@Override
	public URI getPredicate() {
		if(_pred==null)
			_pred=readPredicate();
		return _pred;
	}

	protected abstract URI readPredicate();

	/* (non-Javadoc)
	 * @see org.openrdf.model.Statement#getSubject()
	 */
	@Override
	public Resource getSubject() {
		if(_subj==null)
			_subj = readSubject();
		return _subj;
	}

	protected abstract Resource readSubject();

}
